package com.haotunet.app.goldtreasure.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.goldplusgold.imageloader.lib.GlideRoundTransform;
import com.haotunet.app.goldtreasure.R;
import com.haotunet.app.goldtreasure.activity.DynamicDetailActivity;
import com.haotunet.app.goldtreasure.model.MediaInfo;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/* *
 * Created by Administrator on 2017/7/18.
 */

public class MediaReportAdapter extends HolderAdapter<MediaInfo, MediaReportAdapter.ViewHolder> {
    public MediaReportAdapter(Context context, List<MediaInfo> listData) {
        super(context, listData);
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, MediaInfo mediaInfo, int position) {
        return inflate(R.layout.item_media_report);
    }

    @Override
    public ViewHolder buildHolder(View convertView, MediaInfo mediaInfo, int position) {
        return new ViewHolder(convertView);
    }

    @Override
    public void bindViewDatas(View convertView, ViewHolder holder, final MediaInfo mediaInfo, int position) {
        Glide.with(context).load(mediaInfo.getImageUrl()).placeholder(R.drawable.placeholder_video_find).error(R.drawable.placeholder_video_find).transform(new GlideRoundTransform(context, 2)).into(holder.mediaReportImage);
        holder.mediaReportContent.setText(mediaInfo.getSummary());
        holder.mediaReportTitle.setText(mediaInfo.getTitle());
        convertView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, DynamicDetailActivity.class);
                intent.putExtra("activityUrl", mediaInfo.getLinkUrl());
                intent.putExtra("type", 12);
                context.startActivity(intent);
            }
        });
    }


    static class ViewHolder {
        @InjectView(R.id.media_report_image)
        ImageView mediaReportImage;
        @InjectView(R.id.media_report_title)
        TextView mediaReportTitle;
        @InjectView(R.id.media_report_content)
        TextView mediaReportContent;

        ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }
    }
}
